let instance = null;
export default class AudioPlayer {
	constructor(src) {
		if (instance) {
			return instance;
		}
		const audio = uni.createInnerAudioContext();
		audio.src = src;
		this.audio = audio;
		instance = this;
	}
	// 播放音频
	play() {
		this.audio.play();
	}
	// 暂停音频
	pause() {
		this.audio.pause();
	}
	// 停止音频
	stop() {
		this.audio.stop();
	}
	// 监听音频播放事件
	onPlay(callback) {
		this.audio.onPlay(callback);
	}
	// 监听音频暂停事件
	onPause(callback) {
		this.audio.onPause(callback);
	}
	// 监听音频停止事件
	onStop(callback) {
		this.audio.onStop(callback);
	}
	// 监听音频自然播放结束事件
	onEnded(callback) {
		this.audio.onEnded(callback);
	}
	// 监听音频播放进度更新事件
	onTimeUpdate(callback) {
		this.audio.onTimeUpdate(callback);
	}
	// 监听音频播放错误事件
	onError(callback) {
		this.audio.onError(callback);
	}
}